package script.grammar.expression;

import script.grammar.symbol.NativeType;
import script.grammar.symbol.Type;

public class RelationalOperator extends BinaryOperator {
	private static Type[][] table = {
					//void				boolean				int					double				object
	/*void*/		{NativeType.VOID,	NativeType.VOID,	NativeType.VOID,	NativeType.VOID,	NativeType.VOID},
	/*boolean*/		{NativeType.VOID,	NativeType.VOID,	NativeType.VOID,	NativeType.VOID,	NativeType.VOID},
	/*int*/			{NativeType.VOID,	NativeType.VOID,	NativeType.BOOLEAN,	NativeType.BOOLEAN,	NativeType.VOID},
	/*double*/		{NativeType.VOID,	NativeType.VOID,	NativeType.BOOLEAN,	NativeType.BOOLEAN,	NativeType.VOID},
	/*object*/		{NativeType.VOID,	NativeType.VOID,	NativeType.VOID,	NativeType.VOID,	NativeType.VOID}
	};
	
	public RelationalOperator(String name) {
		super(name);
	}
	
	@Override
	protected Type computeTypeImpl(Type o1, Type o2) {
		return table[o1.getIndex()][o2.getIndex()];
	}
}
